<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>版本信息编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body style="background-color: white;">
    <div class="layui-fluid" id="orderEdit">
        <form class="layui-form layui-form-pane" id="formsubmit" style="width: 500px;margin:20px auto" action="/after/version/save">
        <input type="hidden" name="id" value="${(version.id?c)!''}"/>
            <div class="layui-form-item">
                <label class="layui-form-label">版本名称</label>
                <div class="layui-input-block">
                    <input type="text" name="vername" required lay-verify="required" autocomplete="off" class="layui-input" value="${(version.vername)!''}" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">版本数字</label>
                <div class="layui-input-block">
                    <input type="text" name="verint" required lay-verify="required|number" autocomplete="off" class="layui-input" value="${(version.verint?c)!''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">渠道</label>
                <div class="layui-input-block">
                    <select name="qudaoid">
                        <#list getQdMap?keys as key>
                        <option value="${key!''}" <#if version?exists && version.qudaoid?exists><#if (version.qudaoid)?number == key?number>selected</#if></#if>  > <@mapIntString map=getQdMap key=key/></option>
                        </#list>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" pane>
                <label class="layui-form-label lable-text-center">是否有效</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="state" value="1" lay-skin="switch" lay-text="是|否"  <#if version?exists && version.state?exists && (version.state)?number == 1>checked</#if>  />
                </div>
            </div>
            <div class="layui-form-item" pane>
                <label class="layui-form-label lable-text-center">是否强制更新</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="updatestate" value="1" lay-skin="switch" lay-text="强制|不强制" <#if version?exists && version.updatestate?exists && (version.updatestate)?number == 1>checked</#if>/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">升级下载URL</label>
                <div class="layui-input-block">
                    <input type="text" name="url" required lay-verify="required" autocomplete="off" class="layui-input" value="${(version.url)!''}" />
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">升级内容</label>
                <div class="layui-input-block">
                    <textarea name="content" class="layui-textarea">${(version.content)!''}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save" >&emsp;保存&emsp;</button>
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">&emsp;返回&emsp;</button>
                </div>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function () {
            let $ = layui.$;
            var form = layui.form;
            form.render();

            $.fn.extend({
                serializeObject: function() {
                    var obj = {}; //声明一个对象
                    $.each(this.serializeArray(), function(index, field) {
                        obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                    });
                    return obj;
                }
            });
            form.on('submit('+$("button[lay-submit]:eq(0)").attr("lay-filter")+')', function(data){
                layer.confirm('确认要保存吗？', function (index) {
                    ajaxPost($,$("#formsubmit").attr("action"),$("#formsubmit").serializeObject(),function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 3000}, function(){
                                xadmin.close();
                            });
                        }
                    });
                });
            });
        });
    </script>
</body>

</html>